<%@ page import="com.realtybaron.agent.Agent" %>
<%@ page import="com.realtybaron.agent.Profile" %>
<%@ page import="com.realtybaron.auction.Bid" %>
<%@ page import="com.realtybaron.common.Image" %>
<%--
  Created by IntelliJ IDEA.
  User: marc
  Date: Feb 8, 2010
  Time: 11:28:16 AM
  THIS SOFTWARE IS COPYRIGHTED.  THE SOFTWARE MAY NOT BE COPIED REPRODUCED, TRANSLATED, OR REDUCED TO ANY ELECTRONIC
  MEDIUM OR MACHINE READABLE FORM WITHOUT THE PRIOR WRITTEN CONSENT OF SOCO TECHNOLOGIES.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%
  Bid bid = Bid.class.cast(request.getAttribute("bid"));
  Agent agent = bid.getAgent();
  Profile profile = agent.getProfile();
  Image img = profile.getPhoto();
%>

<html>
<head>
  <title>View Bid</title>
  <link rel="stylesheet" type="text/css" href="<c:url value='style.css' />"/>
</head>
<body>
<div style="width:60em; margin:0 auto;">
  <h1>
    <%=profile.getFull_name()%>
  </h1>

  <h2>About</h2>

  <div style="clear:both;">
    <p>
      <img src="<%=img.getUrl()%>" height="<%=img.getHeight()%>" width="<%=img.getWidth()%>" style="float:left; margin:0 5px 5px 0; padding:0; border:1px solid black;" alt=""/>
      <%=profile.getDescription()%>
    </p>
  </div>
  <div style="clear:both">
    <h2>Profile</h2>

    <p></p>
    <table class="list">
      <tr>
        <td class="label-left">Experience:</td>
        <td><%=profile.getExperience()%>&nbsp;years
        </td>
      </tr>
    </table>
  </div>
  <div style="clear:both;">
    <h2>Recent Sales</h2>

    <p>The following sale transactions were reported by <%=profile.getFull_name()%>. We recommend you ask <%=profile.getFull_name()%> to provide documented proof of all sale
      transactions. Sale transactions are typically recorded in the local multiple listing service (MLS).</p>
    <br/>
    <table class="list">
      <thead>
      <tr>
        <th>Address</th>
        <th>Type</th>
        <th>Side</th>
        <th>DOM</th>
        <th>List</th>
        <th>Sale</th>
        <th>$/Sqft</th>
      </tr>
      </thead>
      <tbody>
      <c:set var='sales' value='<%=agent.getSales().getSale()%>'/>
      <c:choose>
        <c:when test='${not empty sales}'>
          <c:forEach var='sale' items='${sales}'>
            <tr>
              <td>${sale.address}</td>
              <td>${sale.property_type}</td>
              <td>${sale.transaction_side}</td>
              <td>${sale.market_days}</td>
              <td>
                <fmt:formatNumber type='currency' pattern='$#,###' value='${sale.list_price_original}'/>
              </td>
              <td>
                <fmt:formatNumber type='currency' pattern='$#,###' value='${sale.sale_price_final}'/>
              </td>
              <td>
                <fmt:formatNumber type='currency' value='${sale.price_per_size_unit}'/>
              </td>
            </tr>
          </c:forEach>
        </c:when>
        <c:otherwise>
          <tr>
            <td colspan="7" style="text-align:center;">This agent has not reported any recent sales.</td>
          </tr>
        </c:otherwise>
      </c:choose>
      </tbody>
    </table>
    <h2>Client Reviews</h2>

    <p>The following reviews have been recorded on behalf of <%=profile.getFull_name()%>. We attempt to establish the authenticity of each review, but recommend you contact each
      person to get verbal confirmation of their review.</p>
    <br/>
    <table class="list">
      <colgroup>
        <col width="30%"/>
        <col width="10%"/>
        <col width="10%"/>
        <col width="50%"/>
      </colgroup>
      <thead>
      <tr>
        <th>Name/Email</th>
        <th>Satisfied?</th>
        <th>Recommend?</th>
        <th>Comments</th>
      </tr>
      </thead>
      <tbody>
      <c:set var='reviews' value='<%=agent.getReviews().getReview()%>'/>
      <c:choose>
        <c:when test='${not empty reviews}'>
          <c:forEach var='review' items='${reviews}'>
            <tr>
              <td><a href="mailto:${review.email}">${review.name}</a></td>
              <td>${review.satisfied}</td>
              <td>${review.recommend}</td>
              <td style="text-align:left;">${review.comment}</td>
            </tr>
          </c:forEach>
        </c:when>
        <c:otherwise>
          <tr>
            <td colspan="4" style="text-align:center;">This agent has not received any reviews.</td>
          </tr>
        </c:otherwise>
      </c:choose>
      </tbody>
    </table>
  </div>
</div>
</body>
</html>